<!-- HTML header for doxygen 1.8.13-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Hardware Abstraction Layer (HAL)</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen_style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><a href="http://www.cypress.com/"><img alt="Logo" src="logo.png"/></a></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Hardware Abstraction Layer (HAL)</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.2 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('group__group__hal__comp.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#groups">API Reference</a> &#124;
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#typedef-members">Typedefs</a> &#124;
<a href="#enum-members">Enumerations</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle"><div class="title">COMP (Analog Comparator)<div class="ingroups"><a class="el" href="group__group__hal.html">HAL Drivers</a></div></div></div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">General Description</h2>
<p >High level interface for interacting with an analog Comparator. </p>
<h1><a class="anchor" id="cyhal_comp_features"></a>
Features</h1>
<p >The analog comparator measures one input voltage from the non-inverting pin against a second voltage provided on the inverting pin. The result of this comparison can be used in three ways:</p><ul>
<li>Output to pin</li>
<li>Read state via firmware (see <a class="el" href="group__group__hal__comp.html#ga6b4cece78ae5cd76db2fb93493914e8d">cyhal_comp_read</a>)</li>
<li>Event triggered on rising or falling edge (see <a class="el" href="group__group__hal__comp.html#ga9ce3883df3861eb47c5b1e3c079edc37">cyhal_comp_event_t</a>)</li>
</ul>
<p >These three abilities can be used in any combination.</p>
<h1><a class="anchor" id="cyhal_comp_quickstart"></a>
Quickstart</h1>
<p >Call <a class="el" href="group__group__hal__comp.html#ga5cc60c08506afdf99bd847289b67bd7d">cyhal_comp_init</a> to initialize a comparator instance by providing the comparator object (<b>obj</b>), non-inverting input pin (<b>vin_p</b>), inverting input pin (<b>vin_m</b>), optional output pin (<b>output</b>), and configuration (<b>cfg</b>).</p>
<p >Use <a class="el" href="group__group__hal__comp.html#ga6b4cece78ae5cd76db2fb93493914e8d">cyhal_comp_read</a> to read the comparator state from firmware.</p>
<p >Use <a class="el" href="group__group__hal__comp.html#ga0baa90d0b7b567226d997fbc09e07843">cyhal_comp_register_callback</a> and <a class="el" href="group__group__hal__comp.html#ga101a186f1f62ae222e9a7fae8256ee63">cyhal_comp_enable_event</a> to configure a callback that will be invoked on a rising and/or falling edge of the comparator output.</p>
<h1><a class="anchor" id="subsection_comp_snippets"></a>
Code Snippets:</h1>
<dl class="section note"><dt>Note</dt><dd>Error checking is omitted for clarity </dd></dl>
<h1><a class="anchor" id="subsection_comp_snippet_1"></a>
Snippet 1: Comparator initialization</h1>
<p >The following snippet initializes the comparator and powers it on </p><div class="fragment"><div class="line">    <a class="code hl_typedef" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>           rslt;</div>
<div class="line">    <a class="code hl_struct" href="group__group__hal__impl__hw__types.html#structcyhal__comp__t">cyhal_comp_t</a>        comp_obj;</div>
<div class="line">    <a class="code hl_struct" href="group__group__hal__comp.html#structcyhal__comp__config__t">cyhal_comp_config_t</a> config = { .<a class="code hl_variable" href="group__group__hal__comp.html#aa0a64636f172477d20e66a6b735f5145">power</a> = <a class="code hl_enumvalue" href="group__group__hal__general__types.html#gga246fde0e79029f514ce3846b31e366d7a4d8ce140c28177e31de20cf8da8e2a99">CYHAL_POWER_LEVEL_HIGH</a>, .hysteresis = <span class="keyword">false</span> };</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Initialize comparator, using pin PIN_VINP for the input, pin PIN_VINM for the reference and</span></div>
<div class="line">    <span class="comment">// PIN_VOUT for the output</span></div>
<div class="line">    rslt = <a class="code hl_function" href="group__group__hal__comp.html#ga5cc60c08506afdf99bd847289b67bd7d">cyhal_comp_init</a>(&amp;comp_obj, PIN_VINP, PIN_VINM, PIN_VOUT, &amp;config);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Release comparator object after use</span></div>
<div class="line">    <a class="code hl_function" href="group__group__hal__comp.html#ga22b207c986cfda6121fea3a00a5baf67">cyhal_comp_free</a>(&amp;comp_obj);</div>
<div class="ttc" id="agroup__group__hal__comp_html_aa0a64636f172477d20e66a6b735f5145"><div class="ttname"><a href="group__group__hal__comp.html#aa0a64636f172477d20e66a6b735f5145">cyhal_comp_config_t::power</a></div><div class="ttdeci">cyhal_power_level_t power</div><div class="ttdoc">Power mode the comparator should operate in.</div><div class="ttdef"><b>Definition:</b> cyhal_comp.h:125</div></div>
<div class="ttc" id="agroup__group__hal__comp_html_ga22b207c986cfda6121fea3a00a5baf67"><div class="ttname"><a href="group__group__hal__comp.html#ga22b207c986cfda6121fea3a00a5baf67">cyhal_comp_free</a></div><div class="ttdeci">void cyhal_comp_free(cyhal_comp_t *obj)</div><div class="ttdoc">Deinitialize the Comparator peripheral.</div></div>
<div class="ttc" id="agroup__group__hal__comp_html_ga5cc60c08506afdf99bd847289b67bd7d"><div class="ttname"><a href="group__group__hal__comp.html#ga5cc60c08506afdf99bd847289b67bd7d">cyhal_comp_init</a></div><div class="ttdeci">cy_rslt_t cyhal_comp_init(cyhal_comp_t *obj, cyhal_gpio_t vin_p, cyhal_gpio_t vin_m, cyhal_gpio_t output, cyhal_comp_config_t *cfg)</div><div class="ttdoc">Initialize the Comparator peripheral.</div></div>
<div class="ttc" id="agroup__group__hal__comp_html_structcyhal__comp__config__t"><div class="ttname"><a href="group__group__hal__comp.html#structcyhal__comp__config__t">cyhal_comp_config_t</a></div><div class="ttdoc">Configuration options for the Comparator.</div><div class="ttdef"><b>Definition:</b> cyhal_comp.h:123</div></div>
<div class="ttc" id="agroup__group__hal__general__types_html_gga246fde0e79029f514ce3846b31e366d7a4d8ce140c28177e31de20cf8da8e2a99"><div class="ttname"><a href="group__group__hal__general__types.html#gga246fde0e79029f514ce3846b31e366d7a4d8ce140c28177e31de20cf8da8e2a99">CYHAL_POWER_LEVEL_HIGH</a></div><div class="ttdeci">@ CYHAL_POWER_LEVEL_HIGH</div><div class="ttdoc">High comparator power and speed.</div><div class="ttdef"><b>Definition:</b> cyhal_general_types.h:152</div></div>
<div class="ttc" id="agroup__group__hal__impl__hw__types_html_structcyhal__comp__t"><div class="ttname"><a href="group__group__hal__impl__hw__types.html#structcyhal__comp__t">cyhal_comp_t</a></div><div class="ttdoc">Comparator object.</div><div class="ttdef"><b>Definition:</b> cyhal_hw_types.h:566</div></div>
<div class="ttc" id="agroup__group__result_html_gaca79700fcc701534ce61778a9bcf57d1"><div class="ttname"><a href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a></div><div class="ttdeci">uint32_t cy_rslt_t</div><div class="ttdoc">Provides the result of an operation as a structured bitfield.</div><div class="ttdef"><b>Definition:</b> cy_result.h:438</div></div>
</div><!-- fragment --><h1><a class="anchor" id="subsection_comp_snippet_2"></a>
Snippet 2: Comparator read value</h1>
<p >The following snippet reads the current comparator value into a variable </p><div class="fragment"><div class="line">    <a class="code hl_typedef" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>           rslt;</div>
<div class="line">    <a class="code hl_struct" href="group__group__hal__impl__hw__types.html#structcyhal__comp__t">cyhal_comp_t</a>        comp_obj;</div>
<div class="line">    <a class="code hl_struct" href="group__group__hal__comp.html#structcyhal__comp__config__t">cyhal_comp_config_t</a> config = { .<a class="code hl_variable" href="group__group__hal__comp.html#aa0a64636f172477d20e66a6b735f5145">power</a> = <a class="code hl_enumvalue" href="group__group__hal__general__types.html#gga246fde0e79029f514ce3846b31e366d7a4d8ce140c28177e31de20cf8da8e2a99">CYHAL_POWER_LEVEL_HIGH</a>, .hysteresis = <span class="keyword">false</span> };</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Initialize comparator, using pin PIN_VINP for the input and pin PIN_VINM for the reference.</span></div>
<div class="line">    <span class="comment">// No output pin is used.</span></div>
<div class="line">    rslt = <a class="code hl_function" href="group__group__hal__comp.html#ga5cc60c08506afdf99bd847289b67bd7d">cyhal_comp_init</a>(&amp;comp_obj, PIN_VINP, PIN_VINM, <a class="code hl_enumvalue" href="group__group__hal__impl__pin__package__psoc6__01__104__m__csp__ble.html#gga707195ce0627016bf371643bdd9caa51a3dbd1016ea99d087d747530418b89a01">NC</a>, &amp;config);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Read the comparator value</span></div>
<div class="line">    <span class="keywordtype">bool</span> comp_value = <a class="code hl_function" href="group__group__hal__comp.html#ga6b4cece78ae5cd76db2fb93493914e8d">cyhal_comp_read</a>(&amp;comp_obj);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Release comparator object after use</span></div>
<div class="line">    <a class="code hl_function" href="group__group__hal__comp.html#ga22b207c986cfda6121fea3a00a5baf67">cyhal_comp_free</a>(&amp;comp_obj);</div>
<div class="line"> </div>
<div class="ttc" id="agroup__group__hal__comp_html_ga6b4cece78ae5cd76db2fb93493914e8d"><div class="ttname"><a href="group__group__hal__comp.html#ga6b4cece78ae5cd76db2fb93493914e8d">cyhal_comp_read</a></div><div class="ttdeci">bool cyhal_comp_read(cyhal_comp_t *obj)</div><div class="ttdoc">Reads the Comparator state.</div></div>
<div class="ttc" id="agroup__group__hal__impl__pin__package__psoc6__01__104__m__csp__ble_html_gga707195ce0627016bf371643bdd9caa51a3dbd1016ea99d087d747530418b89a01"><div class="ttname"><a href="group__group__hal__impl__pin__package__psoc6__01__104__m__csp__ble.html#gga707195ce0627016bf371643bdd9caa51a3dbd1016ea99d087d747530418b89a01">NC</a></div><div class="ttdeci">@ NC</div><div class="ttdoc">No Connect/Invalid Pin.</div><div class="ttdef"><b>Definition:</b> cyhal_psoc6_01_104_m_csp_ble.h:53</div></div>
</div><!-- fragment --><h1><a class="anchor" id="subsection_comp_snippet_3"></a>
Snippet 3: Comparator event registration</h1>
<p >The following snippet registers a callback that will be called on either a rising or falling edge of the comparator output. </p><div class="fragment"><div class="line"><span class="keyword">static</span> <span class="keywordtype">void</span> comp_event_handler(<span class="keywordtype">void</span>* arg, <a class="code hl_enumeration" href="group__group__hal__comp.html#ga9ce3883df3861eb47c5b1e3c079edc37">cyhal_comp_event_t</a> event)</div>
<div class="line">{</div>
<div class="line">    CY_UNUSED_PARAMETER(arg);</div>
<div class="line">    <span class="comment">// Note: arg is configured below to be a pointer to the cyhal_comp_t instance that caused the</span></div>
<div class="line">    <span class="comment">//       event</span></div>
<div class="line">    <span class="keywordflow">if</span> (0u != (event &amp; <a class="code hl_enumvalue" href="group__group__hal__comp.html#gga9ce3883df3861eb47c5b1e3c079edc37ae1b5c576161fce50484626bcffd1d46d">CYHAL_COMP_RISING_EDGE</a>))</div>
<div class="line">    {</div>
<div class="line">        <span class="comment">// Handle rising edge</span></div>
<div class="line">    }</div>
<div class="line">    <span class="keywordflow">if</span> (0u != (event &amp; <a class="code hl_enumvalue" href="group__group__hal__comp.html#gga9ce3883df3861eb47c5b1e3c079edc37a77b4bfbf8689a798c2baeb7d054e0e96">CYHAL_COMP_FALLING_EDGE</a>))</div>
<div class="line">    {</div>
<div class="line">        <span class="comment">// Handle falling edge</span></div>
<div class="line">    }</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> snippet_cyhal_comp_event_handling(<span class="keywordtype">void</span>)</div>
<div class="line">{</div>
<div class="line">    <a class="code hl_struct" href="group__group__hal__impl__hw__types.html#structcyhal__comp__t">cyhal_comp_t</a> comp_obj;</div>
<div class="line">    <span class="comment">// Initialize the object as shown in Snippet 1</span></div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Register a callback and set the callback argument to be a pointer to the comparator object,</span></div>
<div class="line">    <span class="comment">// so that we can easily reference it from the callback handler.</span></div>
<div class="line">    <a class="code hl_function" href="group__group__hal__comp.html#ga0baa90d0b7b567226d997fbc09e07843">cyhal_comp_register_callback</a>(&amp;comp_obj, &amp;comp_event_handler, &amp;comp_obj);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Subscribe to both the rising and falling edges, so that the event handler is called whenever</span></div>
<div class="line">    <span class="comment">// the comparator output changes</span></div>
<div class="line">    <a class="code hl_function" href="group__group__hal__comp.html#ga101a186f1f62ae222e9a7fae8256ee63">cyhal_comp_enable_event</a>(&amp;comp_obj,</div>
<div class="line">                            (<a class="code hl_enumeration" href="group__group__hal__comp.html#ga9ce3883df3861eb47c5b1e3c079edc37">cyhal_comp_event_t</a>)(<a class="code hl_enumvalue" href="group__group__hal__comp.html#gga9ce3883df3861eb47c5b1e3c079edc37ae1b5c576161fce50484626bcffd1d46d">CYHAL_COMP_RISING_EDGE</a> | <a class="code hl_enumvalue" href="group__group__hal__comp.html#gga9ce3883df3861eb47c5b1e3c079edc37a77b4bfbf8689a798c2baeb7d054e0e96">CYHAL_COMP_FALLING_EDGE</a>),</div>
<div class="line">                            <a class="code hl_define" href="group__group__hal__impl__hw__types.html#gad822a466fc63847114add720ef84c83a">CYHAL_ISR_PRIORITY_DEFAULT</a>, <span class="keyword">true</span>);</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="ttc" id="agroup__group__hal__comp_html_ga0baa90d0b7b567226d997fbc09e07843"><div class="ttname"><a href="group__group__hal__comp.html#ga0baa90d0b7b567226d997fbc09e07843">cyhal_comp_register_callback</a></div><div class="ttdeci">void cyhal_comp_register_callback(cyhal_comp_t *obj, cyhal_comp_event_callback_t callback, void *callback_arg)</div><div class="ttdoc">Register/clear a callback handler for Comparator events.</div></div>
<div class="ttc" id="agroup__group__hal__comp_html_ga101a186f1f62ae222e9a7fae8256ee63"><div class="ttname"><a href="group__group__hal__comp.html#ga101a186f1f62ae222e9a7fae8256ee63">cyhal_comp_enable_event</a></div><div class="ttdeci">void cyhal_comp_enable_event(cyhal_comp_t *obj, cyhal_comp_event_t event, uint8_t intr_priority, bool enable)</div><div class="ttdoc">Enable or Disable a Comparator event.</div></div>
<div class="ttc" id="agroup__group__hal__comp_html_ga9ce3883df3861eb47c5b1e3c079edc37"><div class="ttname"><a href="group__group__hal__comp.html#ga9ce3883df3861eb47c5b1e3c079edc37">cyhal_comp_event_t</a></div><div class="ttdeci">cyhal_comp_event_t</div><div class="ttdoc">Comparator event types.</div><div class="ttdef"><b>Definition:</b> cyhal_comp.h:116</div></div>
<div class="ttc" id="agroup__group__hal__comp_html_gga9ce3883df3861eb47c5b1e3c079edc37a77b4bfbf8689a798c2baeb7d054e0e96"><div class="ttname"><a href="group__group__hal__comp.html#gga9ce3883df3861eb47c5b1e3c079edc37a77b4bfbf8689a798c2baeb7d054e0e96">CYHAL_COMP_FALLING_EDGE</a></div><div class="ttdeci">@ CYHAL_COMP_FALLING_EDGE</div><div class="ttdoc">Falling edge on comparator output.</div><div class="ttdef"><b>Definition:</b> cyhal_comp.h:118</div></div>
<div class="ttc" id="agroup__group__hal__comp_html_gga9ce3883df3861eb47c5b1e3c079edc37ae1b5c576161fce50484626bcffd1d46d"><div class="ttname"><a href="group__group__hal__comp.html#gga9ce3883df3861eb47c5b1e3c079edc37ae1b5c576161fce50484626bcffd1d46d">CYHAL_COMP_RISING_EDGE</a></div><div class="ttdeci">@ CYHAL_COMP_RISING_EDGE</div><div class="ttdoc">Rising edge on comparator output.</div><div class="ttdef"><b>Definition:</b> cyhal_comp.h:117</div></div>
<div class="ttc" id="agroup__group__hal__impl__hw__types_html_gad822a466fc63847114add720ef84c83a"><div class="ttname"><a href="group__group__hal__impl__hw__types.html#gad822a466fc63847114add720ef84c83a">CYHAL_ISR_PRIORITY_DEFAULT</a></div><div class="ttdeci">#define CYHAL_ISR_PRIORITY_DEFAULT</div><div class="ttdoc">Priority that is applied by default to all drivers when initialized.</div><div class="ttdef"><b>Definition:</b> cyhal_hw_types.h:114</div></div>
</div><!-- fragment --><h1><a class="anchor" id="subsection_comp_snippet_4"></a>
Snippet 4: Comparator powering-off and on</h1>
<p >The following snippet demonstrates temporarily powering-off the comparator without freeing it. </p><div class="fragment"><div class="line">    <span class="comment">// This assumes that the comparator has already been initialized as shown in snippet 1 or 2</span></div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Power-on the comparator</span></div>
<div class="line">    rslt = <a class="code hl_function" href="group__group__hal__comp.html#ga3808f1cb24f0dd6dc9d16152667649de">cyhal_comp_set_power</a>(&amp;comp_obj, <a class="code hl_enumvalue" href="group__group__hal__general__types.html#gga246fde0e79029f514ce3846b31e366d7a6f0f4df45e9cac012a2c8e5ba736241b">CYHAL_POWER_LEVEL_DEFAULT</a>);</div>
<div class="line"> </div>
<div class="line">    rslt = <a class="code hl_function" href="group__group__hal__comp.html#ga3808f1cb24f0dd6dc9d16152667649de">cyhal_comp_set_power</a>(&amp;comp_obj, <a class="code hl_enumvalue" href="group__group__hal__general__types.html#gga246fde0e79029f514ce3846b31e366d7a0f601c5d5843c59e58ee1988dd0e6861">CYHAL_POWER_LEVEL_OFF</a>);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// When the comparator is needed again, power it back on</span></div>
<div class="line">    rslt = <a class="code hl_function" href="group__group__hal__comp.html#ga3808f1cb24f0dd6dc9d16152667649de">cyhal_comp_set_power</a>(&amp;comp_obj, <a class="code hl_enumvalue" href="group__group__hal__general__types.html#gga246fde0e79029f514ce3846b31e366d7a6f0f4df45e9cac012a2c8e5ba736241b">CYHAL_POWER_LEVEL_DEFAULT</a>);</div>
<div class="ttc" id="agroup__group__hal__comp_html_ga3808f1cb24f0dd6dc9d16152667649de"><div class="ttname"><a href="group__group__hal__comp.html#ga3808f1cb24f0dd6dc9d16152667649de">cyhal_comp_set_power</a></div><div class="ttdeci">cy_rslt_t cyhal_comp_set_power(cyhal_comp_t *obj, cyhal_power_level_t power)</div><div class="ttdoc">Changes the current operating power level of the comparator.</div></div>
<div class="ttc" id="agroup__group__hal__general__types_html_gga246fde0e79029f514ce3846b31e366d7a0f601c5d5843c59e58ee1988dd0e6861"><div class="ttname"><a href="group__group__hal__general__types.html#gga246fde0e79029f514ce3846b31e366d7a0f601c5d5843c59e58ee1988dd0e6861">CYHAL_POWER_LEVEL_OFF</a></div><div class="ttdeci">@ CYHAL_POWER_LEVEL_OFF</div><div class="ttdoc">Power-off the comparator, while retaining configuration.</div><div class="ttdef"><b>Definition:</b> cyhal_general_types.h:146</div></div>
<div class="ttc" id="agroup__group__hal__general__types_html_gga246fde0e79029f514ce3846b31e366d7a6f0f4df45e9cac012a2c8e5ba736241b"><div class="ttname"><a href="group__group__hal__general__types.html#gga246fde0e79029f514ce3846b31e366d7a6f0f4df45e9cac012a2c8e5ba736241b">CYHAL_POWER_LEVEL_DEFAULT</a></div><div class="ttdeci">@ CYHAL_POWER_LEVEL_DEFAULT</div><div class="ttdoc">Default comparator power and speed.</div><div class="ttdef"><b>Definition:</b> cyhal_general_types.h:154</div></div>
</div><!-- fragment --> <table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="groups" name="groups"></a>
API Reference</h2></td></tr>
<tr class="memitem:group__group__hal__results__comp"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__results__comp.html">Comparator HAL Results</a></td></tr>
<tr class="memdesc:group__group__hal__results__comp"><td class="mdescLeft">&#160;</td><td class="mdescRight">Comparator specific return codes. <br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="nested-classes" name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr class="memitem:structcyhal__comp__config__t"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__comp.html#structcyhal__comp__config__t">cyhal_comp_config_t</a></td></tr>
<tr class="memdesc:structcyhal__comp__config__t"><td class="mdescLeft">&#160;</td><td class="mdescRight">Configuration options for the Comparator.  <a href="group__group__hal__comp.html#structcyhal__comp__config__t">More...</a><br /></td></tr>
<tr class="separator:structcyhal__comp__config__t"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="typedef-members" name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:gac0cf713e6a1b5bca220e9da2f60a8d9e"><td class="memItemLeft" align="right" valign="top">typedef void(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__comp.html#gac0cf713e6a1b5bca220e9da2f60a8d9e">cyhal_comp_event_callback_t</a>) (void *callback_arg, <a class="el" href="group__group__hal__comp.html#ga9ce3883df3861eb47c5b1e3c079edc37">cyhal_comp_event_t</a> event)</td></tr>
<tr class="memdesc:gac0cf713e6a1b5bca220e9da2f60a8d9e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Handler for Comparator events.  <a href="group__group__hal__comp.html#gac0cf713e6a1b5bca220e9da2f60a8d9e">More...</a><br /></td></tr>
<tr class="separator:gac0cf713e6a1b5bca220e9da2f60a8d9e"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="enum-members" name="enum-members"></a>
Enumerations</h2></td></tr>
<tr class="memitem:ga9ce3883df3861eb47c5b1e3c079edc37"><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__comp.html#ga9ce3883df3861eb47c5b1e3c079edc37">cyhal_comp_event_t</a> { <br />
&#160;&#160;<a class="el" href="group__group__hal__comp.html#gga9ce3883df3861eb47c5b1e3c079edc37ae1b5c576161fce50484626bcffd1d46d">CYHAL_COMP_RISING_EDGE</a> = 0x01
, <br />
&#160;&#160;<a class="el" href="group__group__hal__comp.html#gga9ce3883df3861eb47c5b1e3c079edc37a77b4bfbf8689a798c2baeb7d054e0e96">CYHAL_COMP_FALLING_EDGE</a> = 0x02
<br />
 }</td></tr>
<tr class="memdesc:ga9ce3883df3861eb47c5b1e3c079edc37"><td class="mdescLeft">&#160;</td><td class="mdescRight">Comparator event types.  <a href="group__group__hal__comp.html#ga9ce3883df3861eb47c5b1e3c079edc37">More...</a><br /></td></tr>
<tr class="separator:ga9ce3883df3861eb47c5b1e3c079edc37"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga5cc60c08506afdf99bd847289b67bd7d"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__comp.html#ga5cc60c08506afdf99bd847289b67bd7d">cyhal_comp_init</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__comp__t">cyhal_comp_t</a> *obj, <a class="el" href="group__group__hal__impl__pin__package__psoc6__01__104__m__csp__ble.html#ga707195ce0627016bf371643bdd9caa51">cyhal_gpio_t</a> vin_p, <a class="el" href="group__group__hal__impl__pin__package__psoc6__01__104__m__csp__ble.html#ga707195ce0627016bf371643bdd9caa51">cyhal_gpio_t</a> vin_m, <a class="el" href="group__group__hal__impl__pin__package__psoc6__01__104__m__csp__ble.html#ga707195ce0627016bf371643bdd9caa51">cyhal_gpio_t</a> output, <a class="el" href="group__group__hal__comp.html#structcyhal__comp__config__t">cyhal_comp_config_t</a> *cfg)</td></tr>
<tr class="memdesc:ga5cc60c08506afdf99bd847289b67bd7d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialize the Comparator peripheral.  <a href="group__group__hal__comp.html#ga5cc60c08506afdf99bd847289b67bd7d">More...</a><br /></td></tr>
<tr class="separator:ga5cc60c08506afdf99bd847289b67bd7d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gac984ec1ca88e0de51a47aa70601549a6"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__comp.html#gac984ec1ca88e0de51a47aa70601549a6">cyhal_comp_init_cfg</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__comp__t">cyhal_comp_t</a> *obj, const <a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__comp__configurator__t">cyhal_comp_configurator_t</a> *cfg)</td></tr>
<tr class="memdesc:gac984ec1ca88e0de51a47aa70601549a6"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialize the comparator peripheral using a configurator generated configuration struct.  <a href="group__group__hal__comp.html#gac984ec1ca88e0de51a47aa70601549a6">More...</a><br /></td></tr>
<tr class="separator:gac984ec1ca88e0de51a47aa70601549a6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga22b207c986cfda6121fea3a00a5baf67"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__comp.html#ga22b207c986cfda6121fea3a00a5baf67">cyhal_comp_free</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__comp__t">cyhal_comp_t</a> *obj)</td></tr>
<tr class="memdesc:ga22b207c986cfda6121fea3a00a5baf67"><td class="mdescLeft">&#160;</td><td class="mdescRight">Deinitialize the Comparator peripheral.  <a href="group__group__hal__comp.html#ga22b207c986cfda6121fea3a00a5baf67">More...</a><br /></td></tr>
<tr class="separator:ga22b207c986cfda6121fea3a00a5baf67"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga3808f1cb24f0dd6dc9d16152667649de"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__comp.html#ga3808f1cb24f0dd6dc9d16152667649de">cyhal_comp_set_power</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__comp__t">cyhal_comp_t</a> *obj, <a class="el" href="group__group__hal__general__types.html#ga246fde0e79029f514ce3846b31e366d7">cyhal_power_level_t</a> power)</td></tr>
<tr class="memdesc:ga3808f1cb24f0dd6dc9d16152667649de"><td class="mdescLeft">&#160;</td><td class="mdescRight">Changes the current operating power level of the comparator.  <a href="group__group__hal__comp.html#ga3808f1cb24f0dd6dc9d16152667649de">More...</a><br /></td></tr>
<tr class="separator:ga3808f1cb24f0dd6dc9d16152667649de"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga05458b0c95ab66c699787f5fe118fa99"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__comp.html#ga05458b0c95ab66c699787f5fe118fa99">cyhal_comp_configure</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__comp__t">cyhal_comp_t</a> *obj, <a class="el" href="group__group__hal__comp.html#structcyhal__comp__config__t">cyhal_comp_config_t</a> *cfg)</td></tr>
<tr class="memdesc:ga05458b0c95ab66c699787f5fe118fa99"><td class="mdescLeft">&#160;</td><td class="mdescRight">Reconfigure the Comparator.  <a href="group__group__hal__comp.html#ga05458b0c95ab66c699787f5fe118fa99">More...</a><br /></td></tr>
<tr class="separator:ga05458b0c95ab66c699787f5fe118fa99"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga6b4cece78ae5cd76db2fb93493914e8d"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__comp.html#ga6b4cece78ae5cd76db2fb93493914e8d">cyhal_comp_read</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__comp__t">cyhal_comp_t</a> *obj)</td></tr>
<tr class="memdesc:ga6b4cece78ae5cd76db2fb93493914e8d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Reads the Comparator state.  <a href="group__group__hal__comp.html#ga6b4cece78ae5cd76db2fb93493914e8d">More...</a><br /></td></tr>
<tr class="separator:ga6b4cece78ae5cd76db2fb93493914e8d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga0baa90d0b7b567226d997fbc09e07843"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__comp.html#ga0baa90d0b7b567226d997fbc09e07843">cyhal_comp_register_callback</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__comp__t">cyhal_comp_t</a> *obj, <a class="el" href="group__group__hal__comp.html#gac0cf713e6a1b5bca220e9da2f60a8d9e">cyhal_comp_event_callback_t</a> callback, void *callback_arg)</td></tr>
<tr class="memdesc:ga0baa90d0b7b567226d997fbc09e07843"><td class="mdescLeft">&#160;</td><td class="mdescRight">Register/clear a callback handler for Comparator events.  <a href="group__group__hal__comp.html#ga0baa90d0b7b567226d997fbc09e07843">More...</a><br /></td></tr>
<tr class="separator:ga0baa90d0b7b567226d997fbc09e07843"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga101a186f1f62ae222e9a7fae8256ee63"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__comp.html#ga101a186f1f62ae222e9a7fae8256ee63">cyhal_comp_enable_event</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__comp__t">cyhal_comp_t</a> *obj, <a class="el" href="group__group__hal__comp.html#ga9ce3883df3861eb47c5b1e3c079edc37">cyhal_comp_event_t</a> event, uint8_t intr_priority, bool enable)</td></tr>
<tr class="memdesc:ga101a186f1f62ae222e9a7fae8256ee63"><td class="mdescLeft">&#160;</td><td class="mdescRight">Enable or Disable a Comparator event.  <a href="group__group__hal__comp.html#ga101a186f1f62ae222e9a7fae8256ee63">More...</a><br /></td></tr>
<tr class="separator:ga101a186f1f62ae222e9a7fae8256ee63"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<hr/><h2 class="groupheader">Data Structure Documentation</h2>
<a name="structcyhal__comp__config__t" id="structcyhal__comp__config__t"></a>
<h2 class="memtitle"><span class="permalink"><a href="#structcyhal__comp__config__t">&#9670;&nbsp;</a></span>cyhal_comp_config_t</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">struct cyhal_comp_config_t</td>
        </tr>
      </table>
</div><div class="memdoc">
<table class="fieldtable">
<tr><th colspan="3">Data Fields</th></tr>
<tr><td class="fieldtype">
<a id="aa0a64636f172477d20e66a6b735f5145" name="aa0a64636f172477d20e66a6b735f5145"></a><a class="el" href="group__group__hal__general__types.html#ga246fde0e79029f514ce3846b31e366d7">cyhal_power_level_t</a></td>
<td class="fieldname">
power</td>
<td class="fielddoc">
Power mode the comparator should operate in. <p >Lower modes save power but operate at lower speed. </p>
</td></tr>
<tr><td class="fieldtype">
<a id="acb59e8dcfb68fd6598abd7a7a88473b8" name="acb59e8dcfb68fd6598abd7a7a88473b8"></a>bool</td>
<td class="fieldname">
hysteresis</td>
<td class="fielddoc">
Whether hysteresis should be used. <p >See the implementation-specific documentation for the hysteresis value </p>
</td></tr>
</table>

</div>
</div>
<h2 class="groupheader">Typedef Documentation</h2>
<a id="gac0cf713e6a1b5bca220e9da2f60a8d9e" name="gac0cf713e6a1b5bca220e9da2f60a8d9e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gac0cf713e6a1b5bca220e9da2f60a8d9e">&#9670;&nbsp;</a></span>cyhal_comp_event_callback_t</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef void(* cyhal_comp_event_callback_t) (void *callback_arg, <a class="el" href="group__group__hal__comp.html#ga9ce3883df3861eb47c5b1e3c079edc37">cyhal_comp_event_t</a> event)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Handler for Comparator events. </p>
<dl class="section note"><dt>Note</dt><dd>Not all hardware is capable of differentiating which type of edge triggered an event when both rising and falling edges are enabled. If the edge cannot be determined, the <code>event</code> argument will be <code>CYHAL_COMP_RISING_EDGE | CYHAL_COMP_FALLING_EDGE</code> </dd></dl>

</div>
</div>
<h2 class="groupheader">Enumeration Type Documentation</h2>
<a id="ga9ce3883df3861eb47c5b1e3c079edc37" name="ga9ce3883df3861eb47c5b1e3c079edc37"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga9ce3883df3861eb47c5b1e3c079edc37">&#9670;&nbsp;</a></span>cyhal_comp_event_t</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">enum <a class="el" href="group__group__hal__comp.html#ga9ce3883df3861eb47c5b1e3c079edc37">cyhal_comp_event_t</a></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Comparator event types. </p>
<table class="fieldtable">
<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><a id="gga9ce3883df3861eb47c5b1e3c079edc37ae1b5c576161fce50484626bcffd1d46d" name="gga9ce3883df3861eb47c5b1e3c079edc37ae1b5c576161fce50484626bcffd1d46d"></a>CYHAL_COMP_RISING_EDGE&#160;</td><td class="fielddoc"><p >Rising edge on comparator output. </p>
</td></tr>
<tr><td class="fieldname"><a id="gga9ce3883df3861eb47c5b1e3c079edc37a77b4bfbf8689a798c2baeb7d054e0e96" name="gga9ce3883df3861eb47c5b1e3c079edc37a77b4bfbf8689a798c2baeb7d054e0e96"></a>CYHAL_COMP_FALLING_EDGE&#160;</td><td class="fielddoc"><p >Falling edge on comparator output. </p>
</td></tr>
</table>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a id="ga5cc60c08506afdf99bd847289b67bd7d" name="ga5cc60c08506afdf99bd847289b67bd7d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga5cc60c08506afdf99bd847289b67bd7d">&#9670;&nbsp;</a></span>cyhal_comp_init()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a> cyhal_comp_init </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__comp__t">cyhal_comp_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__pin__package__psoc6__01__104__m__csp__ble.html#ga707195ce0627016bf371643bdd9caa51">cyhal_gpio_t</a>&#160;</td>
          <td class="paramname"><em>vin_p</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__pin__package__psoc6__01__104__m__csp__ble.html#ga707195ce0627016bf371643bdd9caa51">cyhal_gpio_t</a>&#160;</td>
          <td class="paramname"><em>vin_m</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__pin__package__psoc6__01__104__m__csp__ble.html#ga707195ce0627016bf371643bdd9caa51">cyhal_gpio_t</a>&#160;</td>
          <td class="paramname"><em>output</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__group__hal__comp.html#structcyhal__comp__config__t">cyhal_comp_config_t</a> *&#160;</td>
          <td class="paramname"><em>cfg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Initialize the Comparator peripheral. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[out]</td><td class="paramname">obj</td><td>Pointer to a Comparator object. The caller must allocate the memory for this object but the init function will initialize its contents. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">vin_p</td><td>Non-inverting input pin </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">vin_m</td><td>Inverting input pin </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">output</td><td>Comparator output pin. May be <a class="el" href="group__group__hal__impl__pin__package__xmc7200__320__bga.html#ggad38839a2406ac562d708d7639fbff225a3dbd1016ea99d087d747530418b89a01">NC</a>. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">cfg</td><td>Configuration structure </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The status of the init request </dd></dl>

</div>
</div>
<a id="gac984ec1ca88e0de51a47aa70601549a6" name="gac984ec1ca88e0de51a47aa70601549a6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gac984ec1ca88e0de51a47aa70601549a6">&#9670;&nbsp;</a></span>cyhal_comp_init_cfg()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a> cyhal_comp_init_cfg </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__comp__t">cyhal_comp_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__comp__configurator__t">cyhal_comp_configurator_t</a> *&#160;</td>
          <td class="paramname"><em>cfg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Initialize the comparator peripheral using a configurator generated configuration struct. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[out]</td><td class="paramname">obj</td><td>Pointer to a comparator object. The caller must allocate the memory for this object but the init function will initialize its contents. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">cfg</td><td>Configuration structure generated by a configurator. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The status of the init request </dd></dl>

</div>
</div>
<a id="ga22b207c986cfda6121fea3a00a5baf67" name="ga22b207c986cfda6121fea3a00a5baf67"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga22b207c986cfda6121fea3a00a5baf67">&#9670;&nbsp;</a></span>cyhal_comp_free()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void cyhal_comp_free </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__comp__t">cyhal_comp_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Deinitialize the Comparator peripheral. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>Comparator object </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ga3808f1cb24f0dd6dc9d16152667649de" name="ga3808f1cb24f0dd6dc9d16152667649de"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga3808f1cb24f0dd6dc9d16152667649de">&#9670;&nbsp;</a></span>cyhal_comp_set_power()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a> cyhal_comp_set_power </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__comp__t">cyhal_comp_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__group__hal__general__types.html#ga246fde0e79029f514ce3846b31e366d7">cyhal_power_level_t</a>&#160;</td>
          <td class="paramname"><em>power</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Changes the current operating power level of the comparator. </p>
<p >If the power level is set to <a class="el" href="group__group__hal__general__types.html#gga246fde0e79029f514ce3846b31e366d7a0f601c5d5843c59e58ee1988dd0e6861">CYHAL_POWER_LEVEL_OFF</a>, the comparator will be powered-off but it will retain its configuration, so it is not necessary to reconfigure it when changing the power level from <a class="el" href="group__group__hal__general__types.html#gga246fde0e79029f514ce3846b31e366d7a0f601c5d5843c59e58ee1988dd0e6861">CYHAL_POWER_LEVEL_OFF</a> to any other value.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>Comparator object </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">power</td><td>The power level to set </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The status of the set power request </dd></dl>

</div>
</div>
<a id="ga05458b0c95ab66c699787f5fe118fa99" name="ga05458b0c95ab66c699787f5fe118fa99"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga05458b0c95ab66c699787f5fe118fa99">&#9670;&nbsp;</a></span>cyhal_comp_configure()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a> cyhal_comp_configure </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__comp__t">cyhal_comp_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__group__hal__comp.html#structcyhal__comp__config__t">cyhal_comp_config_t</a> *&#160;</td>
          <td class="paramname"><em>cfg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Reconfigure the Comparator. </p>
<p >This retains the powered state of the comparator. Depending on the implementation, it may be necessary to temporarily deconfigure and/or power off the comparator in order to apply the new configuration. However, if the comparator is powered-off when this function is called, it will remain powered-off after it returns. Likewise, if the comparator is powered-on when this function is called, it will remain powered-on after it returns.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>Comparator object </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">cfg</td><td>New configuration to apply </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The status of the configure request </dd></dl>

</div>
</div>
<a id="ga6b4cece78ae5cd76db2fb93493914e8d" name="ga6b4cece78ae5cd76db2fb93493914e8d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga6b4cece78ae5cd76db2fb93493914e8d">&#9670;&nbsp;</a></span>cyhal_comp_read()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool cyhal_comp_read </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__comp__t">cyhal_comp_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Reads the Comparator state. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>Comparator object </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The Comparator state. True if the non-inverting pin voltage is greater than the inverting pin voltage, false otherwise. </dd></dl>

</div>
</div>
<a id="ga0baa90d0b7b567226d997fbc09e07843" name="ga0baa90d0b7b567226d997fbc09e07843"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga0baa90d0b7b567226d997fbc09e07843">&#9670;&nbsp;</a></span>cyhal_comp_register_callback()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void cyhal_comp_register_callback </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__comp__t">cyhal_comp_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__group__hal__comp.html#gac0cf713e6a1b5bca220e9da2f60a8d9e">cyhal_comp_event_callback_t</a>&#160;</td>
          <td class="paramname"><em>callback</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>callback_arg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Register/clear a callback handler for Comparator events. </p>
<p >This function will be called when one of the events enabled by <a class="el" href="group__group__hal__comp.html#ga101a186f1f62ae222e9a7fae8256ee63">cyhal_comp_enable_event</a> occurs.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>Comparator object </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">callback</td><td>Function to call when the specified event happens </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">callback_arg</td><td>Generic argument that will be provided to the handler when called </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ga101a186f1f62ae222e9a7fae8256ee63" name="ga101a186f1f62ae222e9a7fae8256ee63"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga101a186f1f62ae222e9a7fae8256ee63">&#9670;&nbsp;</a></span>cyhal_comp_enable_event()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void cyhal_comp_enable_event </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__comp__t">cyhal_comp_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__group__hal__comp.html#ga9ce3883df3861eb47c5b1e3c079edc37">cyhal_comp_event_t</a>&#160;</td>
          <td class="paramname"><em>event</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>intr_priority</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>enable</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Enable or Disable a Comparator event. </p>
<p >When an enabled event occurs, the function specified by <a class="el" href="group__group__hal__comp.html#ga0baa90d0b7b567226d997fbc09e07843">cyhal_comp_register_callback</a> will be called.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>Comparator object </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">event</td><td>Comparator event </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">intr_priority</td><td>Priority for NVIC interrupt events </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">enable</td><td>True to turn on event, False to turn off </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part
<div id="nav-path" class="navpath">
    <ul>
        <li class="footer">
            Generated for <b>Hardware Abstraction Layer (HAL)</b> by <b>Cypress Semiconductor Corporation</b>.
            All rights reserved.
        </li>
    </ul>
</div>
-->
</body>
</html>
